home *** CD-ROM | disk | FTP | other *** search
/ Risc World 5 / Risc World 5.iso / SOFTWARE / Issue3 / Games / xrick / !xrick / src / c / e_box < prev    next >
Text File  |  2004-06-24  |  2KB  |  111 lines

  1. /*
  2.  * xrick/src/e_box.c
  3.  *
  4.  * Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net). All rights reserved.
  5.  *
  6.  * The use and distribution terms for this software are contained in the file
  7.  * named README, which can be found in the root of this distribution. By
  8.  * using this software in any fashion, you are agreeing to be bound by the
  9.  * terms of this license.
  10.  *
  11.  * You must not remove this notice, or any other, from this software.
  12.  */
  13.  
  14. #include "system.h"
  15. #include "game.h"
  16. #include "ents.h"
  17. #include "e_box.h"
  18.  
  19. #include "e_bullet.h"
  20. #include "e_bomb.h"
  21. #include "e_rick.h"
  22. #include "maps.h"
  23. #include "util.h"
  24.  
  25. /*
  26.  * FIXME this is because the same structure is used
  27.  * for all entities. Need to replace this w/ an inheritance
  28.  * solution.
  29.  */
  30. #define cnt c1
  31.  
  32. /*
  33.  * Constants
  34.  */
  35. #define SEQ_INIT 0x0A
  36.  
  37. /*
  38.  * Prototypes
  39.  */
  40. static void explode(U8);
  41.  
  42. /*
  43.  * Entity action
  44.  *
  45.  * ASM 245A
  46.  */
  47. void
  48. e_box_action(U8 e)
  49. {
  50.     static U8 sp[] = {0x24, 0x25, 0x26, 0x27, 0x28};  /* explosion sprites sequence */
  51.  
  52.     if (ent_ents[e].n & ENT_LETHAL) {
  53.         /*
  54.          * box is lethal i.e. exploding
  55.          * play sprites sequence then stop
  56.          */
  57.         ent_ents[e].sprite = sp[ent_ents[e].cnt >> 1];
  58.         if (--ent_ents[e].cnt == 0) {
  59.             ent_ents[e].n = 0;
  60.             map_marks[ent_ents[e].mark].ent |= MAP_MARK_NACT;
  61.         }
  62.     } else {
  63.         /*
  64.          * not lethal: check to see if triggered
  65.          */
  66.         if (e_rick_boxtest(e)) {
  67.             /* rick: collect bombs or bullets and stop */
  68. #ifdef ENABLE_SOUND
  69.             syssnd_play(WAV_BOX, 1);
  70. #endif
  71.             if (ent_ents[e].n == 0x10)
  72.                 game_bombs = GAME_BOMBS_INIT;
  73.             else  /* 0x11 */
  74.                 game_bullets = GAME_BULLETS_INIT;
  75.             ent_ents[e].n = 0;
  76.             map_marks[ent_ents[e].mark].ent |= MAP_MARK_NACT;
  77.         }
  78.         else if (E_RICK_STTST(E_RICK_STSTOP) &&
  79.                 u_fboxtest(e, e_rick_stop_x, e_rick_stop_y)) {
  80.             /* rick's stick: explode */
  81.             explode(e);
  82.         }
  83.         else if (E_BULLET_ENT.n && u_fboxtest(e, e_bullet_xc, e_bullet_yc)) {
  84.             /* bullet: explode (and stop bullet) */
  85.             E_BULLET_ENT.n = 0;
  86.             explode(e);
  87.         }
  88.         else if (e_bomb_lethal && e_bomb_hit(e)) {
  89.             /* bomb: explode */
  90.             explode(e);
  91.         }
  92.     }
  93. }
  94.  
  95.  
  96. /*
  97.  * Explode when
  98.  */
  99. static void explode(U8 e)
  100. {
  101.     ent_ents[e].cnt = SEQ_INIT;
  102.     ent_ents[e].n |= ENT_LETHAL;
  103. #ifdef ENABLE_SOUND
  104.     syssnd_play(WAV_EXPLODE, 1);
  105. #endif
  106. }
  107.  
  108. /* eof */
  109.  
  110.  
  111.